import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
const hideModalTraining = import.meta.env.VITE_APP_HIDDEN_TRAINING === 'true';
interface NavItem {
  label: string;
  subLabel?: string;
  children?: Array<NavItem>;
  href?: string;
  isActive?: boolean;
}
const useNavLink = () => {
  const { t } = useTranslation();
  const location = useLocation();
  let DEFAULT_NAV_ITEMS: Array<NavItem> = useMemo(
    () => [
      {
        label: t('common.generation'),
        href: '/aigc',
      },
      {
        label: t('common.train'),
        href: '/training',
      },
      // {
      //   label: '图片分色',
      //   href: '/colorSeparate',
      // },
    ],
    [t]
  );

  if (hideModalTraining) {
    DEFAULT_NAV_ITEMS = DEFAULT_NAV_ITEMS.filter((i) => i.href !== '/training');
  }

  const NAV_ITEMS = useMemo(() => {
    return DEFAULT_NAV_ITEMS.map((n) => ({
      ...n,
      isActive: n.href === location.pathname,
    }));
  }, [DEFAULT_NAV_ITEMS, location.pathname]);

  return { NAV_ITEMS };
};

export default useNavLink;
